package com.example.mybatis.demo.service;

import com.example.mybatis.demo.mapper.UserInfoMapper;
import com.example.mybatis.demo.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/7/14
 * Time: 21:10
 */
@Service
public class UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    public List<UserInfo> selectUserList() {
        return userInfoMapper.selectAll();
    }

    public UserInfo selectUserByNameAndPassword(String userName, String password) {
        List<UserInfo> userInfos = userInfoMapper.selectUserByName(userName, password);
        if (userInfos.size() > 0) {
            return userInfos.get(0);
        }
        return null;
    }
}
